package com.szr.leex.po.user;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import com.szr.leex.po.base.Auditing;

import lombok.Data;

/**
 * 用户表
 * Created by WangChen on 2018/9/12 11:21.
 */
@Entity
@Table(name = "user")
@Data
public class User extends Auditing<String> {

    @Column(length = 64, unique = true)
    private String name;//用户名，登录使用，不能重复
    @Column(length = 64, unique = true)
    private String code;//工号，不能重复
    @Column(length = 64)
    private String nickname;//昵称，可以重复

    @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    //@JSONField(serialize=false)
    @JoinTable(name = "user_role",
            joinColumns = @JoinColumn(name = "user_id"),
            inverseJoinColumns = @JoinColumn(name = "role_id")
    )
    private List<Role> roleList = new ArrayList<>();

}
